package main

import (
	"flag"
	"fmt"
)

func main() {

	//命令行  test.exe -u root -pwd 1234 -port localhost
	var port int
	var pwd string
	var u string
	//得到port后面的值，如果没有默认是3306
	flag.IntVar(&port, "port", 3306, "端口默认值是3306")
	flag.StringVar(&pwd, "pwd", "", "端口")
	flag.StringVar(&u, "u", "root", "用户")
	flag.Parse()
	// 输出解析结果进行验证
	fmt.Printf("用户: %s\n", u)
	fmt.Printf("密码: %s\n", pwd)
	fmt.Printf("端口: %d\n", port)
}
